#!/bin/bash

currentPath=$(pwd);
currentType=${1};
number=${2};
buildName=${3};

dbugPath=$currentPath/build/dbug_build
apkPath=$currentPath/build/app/outputs/flutter-apk/app-release.apk
if [[ -f "${apkPath}" ]]; then
	rm -rf $apkPath
	echo "删除以前的apk==="
fi
echo "apk start type=${currentType},number=${number},buildName=${buildName}"
if [[ "${currentType}" == "1" ]]; then
	flutter build apk --build-number $number --build-name $buildName --analyze-size --target-platform=android-arm64
else
	flutter build apk --build-number $number --build-name $buildName --obfuscate --split-debug-info=$dbugPath
fi

echo "split-debug-info=${dbugPath}"

if [[ -f "${apkPath}" ]]; then
	#statements
	echo "apk文件存在，path=${apkPath}"
	fir -v
	fir login -T "7e400f8e39be72c2afe96e3084afc37f"
	fir publish $apkPath
	echo "上传到fir成功，打包结束========"
	echo "🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀"
else
	echo "apk文件不存在"
fi
